package com.LeeCode;

/**
 * 删除有序数组中的重复项
 */

public class Code026 {
    public static void main(String[] args) {
        int[] nums = {1, 1, 2};
        System.out.println(new Code026().removeDuplicates(nums));
    }

    public int removeDuplicates(int[] nums) {
        int index = 1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[index] = nums[i];
                index++;
            }
        }
        return index;
    }
}
